<gm:page title="News Map">
<style>
a:link {color: #BC7228;text-decoration: none;}
a:hover {color: #3B4F6A;text-decoration: none;}
a:visited {color: #BC7228;text-decoration: none;}
a:active {color: #3B4F6A;text-decoration: none;}
</style>

<div style="width:980px" align="left">
<gm:tabs target="myContainer"/>

<gm:container id="myContainer">
<!-- 地区头条新闻 -->
<gm:section id="topNews" title="地区头条新闻">
<gm:map id="mapNews" data="${dataLocation}" latref="atom:lat" lngref="atom:long" infotemplate="templateMap">
<gm:handleEvent src="mapNews" event="select" execute="updateFeed();" />
<gm:handleEvent src="listLocation" />
</gm:map>
</gm:section>

<!-- 更多地区新闻 -->
<gm:section id="AllNews" title="更多地区新闻">
<table align="center">
<tr>
<!-- 地区列表 -->
<td style="width:50px" valign="top" id="td_SrcCode">
<gm:list id="listLocation" data="${dataLocation}" template="templateListArea"/>
</td>

<!-- 浮现隐藏按钮 -->
<td width="7" align="center" bordercolor="#333333" bgcolor="#FFFFFF" id="switchLeft" style="cursor:hand" onmouseup="changLeftBar()" isdisp="1">
<img src="resources/arrow_left.gif" alt="关闭/开启页面标题" id="imgLeft" style="cursor:hand"/>
</td>

<!-- 地区新闻列表 -->
<td style="width:auto" valign="top">
<gm:list id="listNewsAll" data="http://news.baidu.com/n?cmd=7&loc=0&name=%B1%B1%BE%A9&tn=rss" pagesize="10" template="templateListNews">
<gm:handleEvent event="repaint" execute="updateMap();" />
</gm:list>
</td>
</tr>
<table>
</gm:section>

<!-- 关于我们 -->
<gm:section id="about" title="关于我们">
<table align="center">
<tr>
<td valign="top">我是Godric Wu，欢迎您的访问！建议用firefox访问！</td>
</tr>
<tr>
<td>email:godric.wu@gmail.com</td>
</tr>
<table>
</gm:section>

</gm:container>
</div>

<!-- 新闻列表模板 -->
<gm:template id="templateListNews">
<table class="blue-theme" border="1" cellpadding="3" cellspacing="1">
<thead>
<tr><td>标题</td>
<td>内容摘要</td>
</tr>
</thead>
<tbody repeat="true">
<tr>
<td><gm:link ref="atom:link/@href" labelref="atom:title" /></td>
<td><gm:html ref="atom:summary" /></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2" align="left">
<gm:pager/>
</td>
</tr>
</tfoot>
</table>
</gm:template>

<!-- 地区列表模板-->
<gm:template id="templateListArea">
<table class="blue-theme" border="1" cellpadding="3" cellspacing="1">
<thead>
<tr><td>地区</td></tr>
</thead>
<tbody repeat="true">
<tr>
<td>
<gm:text ref="atom:title"/>
</td>
</tr>
</tbody>
</table>
</gm:template>

<!-- 地图信息模板-->
<gm:template id="templateMap">
<div id="td_newsList" style="width:300px;height:200px" align="left"></div>
</gm:template>


<!-- 地理译码 -->
<gm:data id="dataLocation">
<atom:feed>
<atom:entry>
<atom:id>1</atom:id>
<atom:title>北京</atom:title>
<atom:lat>39.9</atom:lat>
<atom:long>116.4</atom:long>
</atom:entry>


<atom:entry>
<atom:id>2</atom:id>
<atom:title>上海</atom:title>
<atom:lat>31.2</atom:lat>
<atom:long>121.4</atom:long>
</atom:entry>

<atom:entry>
<atom:id>3</atom:id>
<atom:title>天津</atom:title>
<atom:lat>39.1</atom:lat>
<atom:long>117.2</atom:long>
</atom:entry>

<atom:entry>
<atom:id>4</atom:id>
<atom:title>重庆</atom:title>
<atom:lat>29.5</atom:lat>
<atom:long>106.5</atom:long>
</atom:entry>

<atom:entry>
<atom:id>5</atom:id>
<atom:title>广东</atom:title>
<atom:lat>23.1</atom:lat>
<atom:long>113.2</atom:long>
</atom:entry>

<atom:entry>
<atom:id>6</atom:id>
<atom:title>河北</atom:title>
<atom:lat>38</atom:lat>
<atom:long>114.4</atom:long>
</atom:entry>

<atom:entry>
<atom:id>7</atom:id>
<atom:title>辽宁</atom:title>
<atom:lat>41.8</atom:lat>
<atom:long>123.4</atom:long>
</atom:entry>

<atom:entry>
<atom:id>8</atom:id>
<atom:title>吉林</atom:title>
<atom:lat>43.9</atom:lat>
<atom:long>125.3</atom:long>
</atom:entry>

<atom:entry>
<atom:id>9</atom:id>
<atom:title>甘肃</atom:title>
<atom:lat>36</atom:lat>
<atom:long>103.7</atom:long>
</atom:entry>

<atom:entry>
<atom:id>10</atom:id>
<atom:title>山西</atom:title>
<atom:lat>37.8</atom:lat>
<atom:long>112.5</atom:long>
</atom:entry>

<atom:entry>
<atom:id>11</atom:id>
<atom:title>四川</atom:title>
<atom:lat>30.6</atom:lat>
<atom:long>104.1</atom:long>
</atom:entry>

<atom:entry>
<atom:id>12</atom:id>
<atom:title>陕西</atom:title>
<atom:lat>34.2</atom:lat>
<atom:long>108.9</atom:long>
</atom:entry>

<atom:entry>
<atom:id>13</atom:id>
<atom:title>河南</atom:title>
<atom:lat>34.7</atom:lat>
<atom:long>113.6</atom:long>
</atom:entry>
<atom:entry>
<atom:id>14</atom:id>
<atom:title>山东</atom:title>
<atom:lat>36.6</atom:lat>
<atom:long>117</atom:long>
</atom:entry>
<atom:entry>
<atom:id>15</atom:id>
<atom:title>湖南</atom:title>
<atom:lat>28.2</atom:lat>
<atom:long>112.9</atom:long>
</atom:entry>
<atom:entry>
<atom:id>16</atom:id>
<atom:title>湖北</atom:title>
<atom:lat>30.5</atom:lat>
<atom:long>114.2</atom:long>
</atom:entry>
<atom:entry>
<atom:id>17</atom:id>
<atom:title>江西</atom:title>
<atom:lat>28.6</atom:lat>
<atom:long>115.9</atom:long>
</atom:entry>
<atom:entry>
<atom:id>18</atom:id>
<atom:title>江苏</atom:title>
<atom:lat>32</atom:lat>
<atom:long>118.7</atom:long>
</atom:entry>
<atom:entry>
<atom:id>19</atom:id>
<atom:title>浙江</atom:title>
<atom:lat>30.2</atom:lat>
<atom:long>120.1</atom:long>
</atom:entry>
<atom:entry>
<atom:id>20</atom:id>
<atom:title>安徽</atom:title>
<atom:lat>31.8</atom:lat>
<atom:long>117.3</atom:long>
</atom:entry>
<atom:entry>
<atom:id>21</atom:id>
<atom:title>福建</atom:title>
<atom:lat>26</atom:lat>
<atom:long>119.3</atom:long>
</atom:entry>
<atom:entry>
<atom:id>22</atom:id>
<atom:title>广西</atom:title>
<atom:lat>22.8</atom:lat>
<atom:long>108.3</atom:long>
</atom:entry>
<atom:entry>
<atom:id>23</atom:id>
<atom:title>贵州</atom:title>
<atom:lat>26.6</atom:lat>
<atom:long>106.7</atom:long>
</atom:entry>
<atom:entry>
<atom:id>24</atom:id>
<atom:title>香港</atom:title>
<atom:lat>21.23</atom:lat>
<atom:long>115.12</atom:long>
</atom:entry>
<atom:entry>
<atom:id>25</atom:id>
<atom:title>澳门</atom:title>
<atom:lat>21.33</atom:lat>
<atom:long>115.07</atom:long>
</atom:entry>
<atom:entry>
<atom:id>26</atom:id>
<atom:title>海南</atom:title>
<atom:lat>20</atom:lat>
<atom:long>110.3</atom:long>
</atom:entry>
<atom:entry>
<atom:id>27</atom:id>
<atom:title>台湾</atom:title>
<atom:lat>25</atom:lat>
<atom:long>121.5</atom:long>
</atom:entry>
<atom:entry>
<atom:id>28</atom:id>
<atom:title>云南</atom:title>
<atom:lat>25</atom:lat>
<atom:long>102.7</atom:long>
</atom:entry>
<atom:entry>
<atom:id>29</atom:id>
<atom:title>内蒙古</atom:title>
<atom:lat>40.8</atom:lat>
<atom:long>111.7</atom:long>
</atom:entry>
<atom:entry>
<atom:id>30</atom:id>
<atom:title>青海</atom:title>
<atom:lat>36.6</atom:lat>
<atom:long>101.8</atom:long>
</atom:entry>
<atom:entry>
<atom:id>31</atom:id>
<atom:title>宁夏</atom:title>
<atom:lat>38.4</atom:lat>
<atom:long>106.2</atom:long>
</atom:entry>
<atom:entry>
<atom:id>32</atom:id>
<atom:title>新疆</atom:title>
<atom:lat>43.8</atom:lat>
<atom:long>87.6</atom:long>
</atom:entry>
<atom:entry>
<atom:id>33</atom:id>
<atom:title>西藏</atom:title>
<atom:lat>29.6</atom:lat>
<atom:long>91.1</atom:long>
</atom:entry>
<atom:entry>
<atom:id>34</atom:id>
<atom:title>黑龙江</atom:title>
<atom:lat>45.7</atom:lat>
<atom:long>126.6</atom:long>
</atom:entry>
</atom:feed>
</gm:data>

<script>
//判断是否第一次来到这个页面，如果是flag=0,否则flag=1
var flag = 0;

//新闻列表Module
var listModule;

//rss Url
var rssUrl;

//点击不同地区时，更新新闻data
function updateFeed(){
//titleGPath为地区名称
var titleGPath = new GPath("atom:title");
var entry = google.mashups.getObjectById('mapNews').getSelectedEntry();

if (entry == null) { return; }

var title= titleGPath.getValue(entry);

//根据不同的地区得到不同的rssUrl
selRssUrl(title);

listModule = google.mashups.getObjectById('listNewsAll');

//设置listNewsAll的data属性
listModule.setData(rssUrl );
}


//更新地图上的头条新闻
function updateMap(){
//第一次来到这个页面，do nothing
if(flag==0){flag = 1;return;}

var titleGPathForMap = new GPath("atom:title");
var linkGPathForMap = new GPath("atom:link/@href");

var output="";

var size=listModule.getData().size();

var newsTitle;

var newsLink;

for (var i = 0; i < size; i++) {
newsTitle = titleGPathForMap .getValue(listModule.getData().entryAt(i));
newsLink = linkGPathForMap .getValue(listModule.getData().entryAt(i));
output += "<img src='resources/li.gif'/><a href=" + newsLink + " target=_blank>" + newsTitle + "</a><br>";
}

//修改templateMap中的div内容
document.getElementById("td_newsList").innerHTML = output;
}


/* 开启/关闭左侧的源代码工作区 */
function changLeftBar(){
if (document.getElementById("switchLeft").isdisp==1||document.getElementById("switchLeft").isdisp==undefined){
document.getElementById("switchLeft").isdisp=0;
document.getElementById("imgLeft").src="resources/arrow_right.gif";
document.getElementById("td_SrcCode").style.display="none";
}else{
document.getElementById("switchLeft").isdisp=1;
document.getElementById("imgLeft").src="resources/arrow_left.gif";
document.getElementById("td_SrcCode").style.display="";
}
}

//根据不同的地区选择不同的rss
function selRssUrl(title)
{
if(title=="北京"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=0&name=%B1%B1%BE%A9&tn=rss";
}else if(title=="上海"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=2354&name=%C9%CF%BA%A3&tn=rss";
}else if(title=="天津"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=125&name=%CC%EC%BD%F2&tn=rss";
}else if(title=="重庆"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=6425&name=%D6%D8%C7%EC&tn=rss";
}else if(title=="广东"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=5495&name=%B9%E3%B6%AB&tn=rss";
}else if(title=="河北"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=250&name=%BA%D3%B1%B1&tn=rss";
}else if(title=="辽宁"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=1481&name=%C1%C9%C4%FE&tn=rss";
}else if(title=="吉林"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=1783&name=%BC%AA%C1%D6&tn=rss";
}else if(title=="甘肃"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=8534&name=%B8%CA%CB%E0&tn=rss";
}else if(title=="山西"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=812&name=%C9%BD%CE%F7&tn=rss";
}else if(title=="四川"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=6692&name=%CB%C4%B4%A8&tn=rss";
}else if(title=="陕西"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=8205&name=%C9%C2%CE%F7&tn=rss";
}else if(title=="河南"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=4371&name=%BA%D3%C4%CF&tn=rss";
}else if(title=="山东"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=3996&name=%C9%BD%B6%AB&tn=rss";
}else if(title=="湖南"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=5161&name=%BA%FE%C4%CF&tn=rss";
}else if(title=="湖北"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=4811&name=%BA%FE%B1%B1&tn=rss";
}else if(title=="江西"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=3636&name=%BD%AD%CE%F7&tn=rss";
}else if(title=="江苏"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=2493&name=%BD%AD%CB%D5&tn=rss";
}else if(title=="浙江"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=2809&name=%D5%E3%BD%AD&tn=rss";
}else if(title=="安徽"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=3072&name=%B0%B2%BB%D5&tn=rss";
}else if(title=="福建"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=3372&name=%B8%A3%BD%A8&tn=rss";
}else if(title=="广西"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=5886&name=%B9%E3%CE%F7&tn=rss";
}else if(title=="贵州"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=7230&name=%B9%F3%D6%DD&tn=rss";
}else if(title=="香港"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=9337&name=%CF%E3%B8%DB&tn=rss";
}else if(title=="澳门"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=9436&name=%B0%C4%C3%C5&tn=rss";
}else if(title=="海南"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=6245&name=%BA%A3%C4%CF&tn=rss";
}else if(title=="台湾"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=9442&name=%CC%A8%CD%E5&tn=rss";
}else if(title=="云南"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=7527&name=%D4%C6%C4%CF&tn=rss";
}else if(title=="内蒙古"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=1167&name=%C4%DA%C3%C9%B9%C5&tn=rss";
}else if(title=="青海"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=8782&name=%C7%E0%BA%A3&tn=rss";
}else if(title=="宁夏"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=8907&name=%C4%FE%CF%C4&tn=rss";
}else if(title=="新疆"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=9001&name=%D0%C2%BD%AE&tn=rss";
}else if(title=="西藏"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=7915&name=%CE%F7%B2%D8&tn=rss";
}else if(title=="黑龙江"){
rssUrl = "http://news.baidu.com/n?cmd=7&loc=1967&name=%BA%DA%C1%FA%BD%AD&tn=rss";
}
}


</script>
</gm:page>

